package com.zking.service;

import java.sql.SQLException;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import com.zking.dao.DBPool;
import com.zking.entity.Order;

public class BookService {
	
	//dao中的数据库连接对象
	private DBPool dbPool = DBPool.getInstance();
	private QueryRunner runner = new QueryRunner(dbPool.getDataSource());
	
	//创建订单的方法
	public int createBook(Order order) throws SQLException {
		String sql = "insert into `order` values(NULL,NULL,NULL,NULL,NULL,?,?,NULL,NUll,?)";
		int personNumber = order.getPerson_number().intValue();
		Object[] params = {personNumber,order.getTime(),order.getOrdertime()};
		return runner.execute(sql, params);
	}
	
	public static void main(String[] args) {
		BookService bookService  = new BookService();
		System.out.println(bookService.runner.getClass());
	}
	
	
	
}
